#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtCharts>
#include <QDebug>
#include <QMainWindow>
#include <QMessageBox>
#include <QStatusBar>
#include <QThread>
#include <QTimer>
#include <QScrollBar>

#include "serial.h"
using namespace QtCharts;

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT
signals:
    void sender(QString str);
    void opener(QString portName,QSerialPort::BaudRate baudRate);
    void test(int i,int data);

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    int i = 2;

    Serial *ser1 = new Serial;
    QThread *thread_serial = new QThread;

    QChart *chart = new QChart();
    QSplineSeries *series = new QSplineSeries();//https://blog.csdn.net/danshiming/article/details/139099766
    QChartView *chartView = new QChartView();
    int currentIndex = 0;

    QValueAxis *axisX = new QValueAxis;
    QValueAxis *axisY = new QValueAxis;

    QTimer * timer_serial = new QTimer();//串口刷新定时器

    void connectClicked();
    //图表
    void chartInit();
    void chartDraw(int i,double data);
    void chartMove(int);//图表移动

    void testSin();//利用正弦波进行代码测试
    void serialScan();

    void onScrollBarMoved(int value);
};
#endif // MAINWINDOW_H
